<%@page import="org.omg.PortableInterceptor.ForwardRequest"%>
<%@ page import="java.util.jar.Attributes.Name"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="support.*,java.util.*" %>
    
<%

String cancel = (String) request.getParameter("cancel");
String submit = (String) request.getParameter("submit");
String title;
String message;

if (submit == null){  	// User press cancel
	title = "Cancelation";
	message = "Your application is not stored.";
}
else {
	title = "Confirmation";
	Applicant a = (Applicant) session.getAttribute("applicant");
	if (a != null) {
		DatabaseAccessObject dao = new DatabaseAccessObject();
		int appId = dao.newApplicant(a);
		if (appId != 0) {
			message = "Congratulation! You application has been submitted.<br/>Your application ID: " + 
					  Integer.valueOf(appId);
		}
		else {
			message = "Sorry, there are something wrong!";
		}
		// Kill applicant session to avoid user click previous page
		session.removeAttribute("applicant");   
	}
	else message = "Applicant not exists.";
}
session.setAttribute("title", title);
session.setAttribute("message", message);
response.sendRedirect("result.jsp");

%>
